﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using MpSoft.Library.DTO;

namespace MpSoft.Library.DAO.Categorys
{
    internal class NavigateDAO
    {
        public static List<ENavigate> Navigate_List()
        {
            List<ENavigate> listNav = null;
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(HttpContext.Current.Server.MapPath(@"\Context\Xml\SiteMapAdmin.xml"));
            var listNavNode = xdoc.SelectNodes("//sitemap/navigate");
            if (listNavNode.Count > 0)
            {
                listNav = new List<ENavigate>();
                for (int i = 0; i < listNavNode.Count; i++)
                {
                    var obj = new ENavigate();
                    var node=listNavNode[i];
                    obj.ID = node.Attributes["ID"].Value;
                    obj.Level = node.Attributes["Level"].Value;
                    obj.Show = node.Attributes["Show"].Value;
                    obj.Title = node.Attributes["Title"].Value;
                    obj.Url = node.Attributes["Url"].Value;
                    obj.PathControl = node.Attributes["PathControl"].Value;
                    obj.Parent = node.Attributes["Parent"].Value;
                    listNav.Add(obj);
                }
                return listNav;
            }
            return listNav;
        }
    }
}
